#!/bin/bash
update='./update'
backup='./backup'
today=$(date '+%Y%m%d')
filename=Server_Game.jar
while [ 1 ]
do

if [ ! -d $update ]; then
	mkdir -m $update
	echo 'The update folder is created.'
fi

if [ ! -d $backup ]; then
	mkdir -m $backup
	echo 'The backup folder is created.'
fi

if [ -f $update/$filename ]; then
	chmod -R 777 $update
	echo '檔案權限調整完成' 
  	cp -r $filename $backup/$filename-$today
	echo '檔案備份完成'
	mv $update/$filename .
	echo '檔案更新完成'
else
	echo 'Update無資料,無須更新'
fi

java -jar $filename

done










